﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using FrontRoomCheck.FireAreOutLineAppend;
using YJKRevitCode.ElmentSearchUtility.LinkDocumentSuite;
using YJKRGeometry;
using ModelCheckUtility.ModelLayer;

namespace FrontRoomCheck.Model
{
	public class AdapteDoorResultPakcer
	{
		public FrontRoomDoorPacker m_useRoomDoorPacker
		{
			get
			{
				return this.m_useFrontRoomDoorPacker;
			}
		}

		public EleType ThisType
		{
			get
			{
				return this.m_thisType;
			}
		}

		public bool IfFrontRoomDoor
		{
			get
			{
				return this.m_bifFrontRoomDoor;
			}
		}

		public Element ThisElement
		{
			get
			{
				return this.m_thisElement;
			}
		}

		public RevitLinkInstance UseRevitLinkInstance
		{
			get
			{
				return this.m_useRevitLinkInstance;
			}
		}

		public Level UseLevel
		{
			get
			{
				return this.m_useLevel;
			}
		}

		public ICloseCurveAnalays UseICloseCurveAnalays
		{
			get
			{
				return this.m_useICloseCurveAnalays;
			}
			set
			{
				this.m_useICloseCurveAnalays = value;
			}
		}

		public bool BIsLinkElement
		{
			get
			{
				return this.m_bIsLinkElement;
			}
			set
			{
				this.m_bIsLinkElement = value;
			}
		}

		public AdapteDoorResultPakcer(Def_Sel useOutLinePacker, List<Level> lstSelectLevel)
		{
			this.m_selectLevelInMianDocument.AddRange(lstSelectLevel);
			this.m_useOutLinePacker = useOutLinePacker;
			this.m_thisType = useOutLinePacker.m_kType;
			this.m_bifFrontRoomDoor = false;
			this.m_thisElement = this.m_useOutLinePacker.m_element;
			this.BIsLinkElement = useOutLinePacker.m_bIsLinkEle;
			this.m_useRevitLinkInstance = useOutLinePacker.m_RevitLinkInstance;
			this.m_useLevel = null;
			if (this.m_thisElement != null && this.m_useRevitLinkInstance == null)
			{
				Document document = this.m_thisElement.Document;
				this.m_useLevel = (document.GetElement(this.m_thisElement.LevelId) as Level);
				return;
			}
			if (this.m_thisElement != null && this.m_useRevitLinkInstance != null && this.m_useRevitLinkInstance.GetTotalTransform() != null)
			{
				Document document2 = this.m_thisElement.Document;
				Level level = document2.GetElement(this.m_thisElement.LevelId) as Level;
				if (level != null)
				{
					double num = level.Elevation;
					Transform totalTransform = this.m_useRevitLinkInstance.GetTotalTransform();
					num += LinkDocumentUtility.CalculateTransformEffectOnZ(totalTransform);
					Level useLevel = null;
					double val = double.MaxValue;
					foreach (Level level2 in this.m_selectLevelInMianDocument)
					{
						if (level2 != null)
						{
							double num2 = Math.Abs(num - level2.Elevation);
							if (Geometry.LessThan(num2, val))
							{
								val = num2;
								useLevel = level2;
							}
						}
					}
					this.m_useLevel = useLevel;
				}
			}
		}

		public AdapteDoorResultPakcer(FrontRoomDoorPacker useFrontRoomDoorPacker, ICloseCurveAnalays inputCloseCurve = null)
		{
			this.m_useFrontRoomDoorPacker = useFrontRoomDoorPacker;
			this.m_useICloseCurveAnalays = inputCloseCurve;
			this.m_thisType = EleType.eFrontRoomDoor;
			this.m_bifFrontRoomDoor = true;
			this.m_thisElement = this.m_useFrontRoomDoorPacker.ThisElement;
			this.m_useRevitLinkInstance = this.m_useFrontRoomDoorPacker.UseRevitLinkInstance;
			this.m_useLevel = null;
			if (useFrontRoomDoorPacker.LstConctRooms.Count > 0)
			{
				this.m_useLevel = useFrontRoomDoorPacker.LstConctRooms[0].ThisRoom.Level;
			}
		}

		private Def_Sel m_useOutLinePacker;

		private FrontRoomDoorPacker m_useFrontRoomDoorPacker;

		private ICloseCurveAnalays m_useICloseCurveAnalays;

		private EleType m_thisType;

		private bool m_bifFrontRoomDoor = true;

		private bool m_bIsLinkElement;

		private Element m_thisElement;

		private RevitLinkInstance m_useRevitLinkInstance;

		private Level m_useLevel;

		private int thisElementId = -1;

		private List<Level> m_selectLevelInMianDocument = new List<Level>();
	}
}
